define(function(require, exports, module) {
	var $=require('zepto');
	function Tab() {
		
	}
	module.exports = Tab;
	Tab.prototype.init = function(pageinto) {
		
		var mid=pageinto.id;
		console.log(mid);
		$(".mui-tab-item").each(function(){
			if($(this).attr("href")=="#"+mid){
				if(!$(this).hasClass("mui-active")){
					$(this).addClass("mui-active");
				}
			}else{
				if($(this).hasClass("mui-active")){
					$(this).removeClass("mui-active");
				}
			}
		});
	}
	Tab.prototype.setActive = function(mid) {
		console.log("setActive-->"+mid);
		$(".mui-tab-item").each(function(){
			if($(this).attr("href")=="#"+mid){
				if(!$(this).hasClass("mui-active")){
					$(this).addClass("mui-active");
				}
			}else{
				if($(this).hasClass("mui-active")){
					$(this).removeClass("mui-active");
				}
			}
		});
	}
	Tab.prototype.hide = function() {
		$(".mui-tab-item").hide();
		$("#back").show();
	}
	Tab.prototype.show = function() {
		$(".mui-tab-item").show();
		$("#back").hide();
	}
	Tab.prototype.flag = function(id) {
		if(id=="pageHome"){
			return true;
		}else if(id=="pageQuery"){
			return true;
		}else if(id=="contact"){
			return true;
		}else if(id=="life"){
			return true;
		}else if(id=="setting"){
			return true;
		}else{
			return false;
		}
	}
	Tab.prototype.hf = function(pageinto, pageout) {
		var header = document.querySelector("body > .header"), footer = document.querySelector("body > .footer");
		console.log("----pageout---");
		console.log(pageout);
	// element of link at bottom
		var ele_link_in = null, ele_link_out = null;
		// element of header
		var ele_header_in = null, ele_header_out = null;
		if (pageinto) {
			console.log(1);
			//ele_link_in = footer.querySelector("a[href$="+ pageinto.id +"]");
			ele_header_in = pageinto.querySelector(".header");
			//console.log(ele_header_in);
			if (pageout) {
				console.log(2);
				//ele_link_out = footer.querySelector("a[href$="+ pageout.id +"]");
				ele_header_out = pageout.querySelector("header");
				if($(pageinto).find("header")){
					console.log(7);
					$(header).removeClass("out");
					$(header).addClass("in");
					//header.className = "";	
					//footer.className = "footer in";	
					$(footer).removeClass("out");
					$(footer).addClass("in");		
				}
			} else if (ele_header_in == null) {
				console.log(3);
				$(header).removeClass("out");
				$(header).addClass("in");
				//header.className = "";	
				//footer.className = "footer in";	
				$(footer).removeClass("out");
				$(footer).addClass("in");				
			}
			if (ele_header_in == null) {
				console.log(4);
				//ele_link_in && ele_link_in.classList.add("active");
				ele_link_out && ele_link_out.classList.remove("active");
				
				if (ele_header_out != null) {
					console.log(5);
					header.className = "mui-bar mui-bar-nav header in";	
					footer.className = "mui-bar mui-bar-tab footer in";	
					//$(header).removeClass("in");
					//$(header).addClass("out");
					//header.className = "";	
					//footer.className = "footer in";	
					//$(footer).removeClass("in");
					//$(footer).addClass("out");	
				}
			} else if (pageout && ele_header_out == null) {
				// include header, slide-out fixed header
				console.log(6);
				header.className = "header slide out";	
				footer.className = "footer slide out";	
			}
		}
	}
	
});